<?php


namespace App\Listeners;


use App\Events\OrderDelivery;
use App\Services\OfficialTemplateService;

class OrderDeliveryNoticeListener
{
    public $order;

    /**
     * Handle the event.
     *
     * @param  OrderDelivery $event
     * @return void
     */
    public function handle(OrderDelivery $event)
    {
        $this->order = $event->order;

        /** 通知镖师或镖头 */
        $this->doLegwork();
    }

    private function doLegwork()
    {
        info('通知配送单送达1');
        if(!$this->order->out_trade_no){
            info('通知配送单送达2');
            OfficialTemplateService::sendDeliveryOrder($this->order);
        }
    }
}
